export default {
    // 全屏功能
    fullScreen(id: string = '') {
        const element: any = id
            ? document.getElementById(id)
            : document.documentElement || document.body;
        const requestMethod: any =
            element.requestFullScreen ||
            element.webkitRequestFullScreen ||
            element.mozRequestFullScreen ||
            element.msRequestFullScreen;
        if (requestMethod) {
            requestMethod.call(element);
        } else {
            const { ActiveXObject } = window as any;
            if (typeof ActiveXObject !== 'undefined') {
                const wscript = new ActiveXObject('WScript.Shell');
                if (wscript !== null) {
                    wscript.SendKeys('{F11}');
                }
            }
        }
    },
    // 退出全屏
    fullScreenExit() {
        const exitMethod: any =
            document?.exitFullscreen ||
            document?.webkitExitFullScreen ||
            document?.mozCancelFullScreen ||
            document?.msExitFullScreen;
        if (exitMethod) {
            document.fullscreenElement !== null && exitMethod.call(document);
        } else {
            const { ActiveXObject } = window as any;
            if (typeof ActiveXObject !== 'undefined') {
                const wscript = new ActiveXObject('WScript.Shell');
                if (wscript !== null) {
                    wscript.SendKeys('{F11}');
                }
            }
        }
    },
    // 全屏
    fullScreenDo(callback: any = null) {
        if (document.fullscreenElement) {
            this.fullScreenExit();
        } else {
            this.fullScreen();
        }
        if (callback) {
            callback();
        }
    },
};
